import http from "@/api/http";

class MicroCamundaApi {
  readonly url: string = "";
  constructor(url: string) {
    this.url = url;
  }

  getProcessModel = (processDefinitionId: String): Promise<any> => {
    return http.get(this.url + "/getProcessModel", { processDefinitionId });
  };
  getTaskModel = (taskId: String): Promise<any> => {
    return http.get(this.url + "/getTaskModel", { taskId });
  };
  getInstanceModel = (processInstanceId: String): Promise<any> => {
    return http.get(this.url + "/getInstanceModel", { processInstanceId });
  };
  listHistoryRecordByTaskId = (taskId: String): Promise<any> => {
    return http.get(this.url + "/listHistoryRecordByTaskId", { taskId });
  };
  listHistoryRecordByProcessInstanceId = (processInstanceId: String): Promise<any> => {
    return http.get(this.url + "/listHistoryRecordByProcessInstanceId", { processInstanceId });
  };
  deploy = (params: any): Promise<any> => {
    return http.post(this.url + "/deploy", params);
  };
  start = (params: any): Promise<any> => {
    return http.post(this.url + "/start", params);
  };
  approve = (params: any): Promise<any> => {
    return http.post(this.url + "/approve", params);
  };
  transfer = (params: any): Promise<any> => {
    return http.post(this.url + "/transfer", params);
  };
  delegate = (params: any): Promise<any> => {
    return http.post(this.url + "/delegate", params);
  };
  reject = (taskId: String): Promise<any> => {
    return http.get(this.url + "/reject", { taskId });
  };
  convertToModelByTaskId = (taskId: String): Promise<any> => {
    return http.get(this.url + "/convertToModelByTaskId", { taskId });
  };
  convertToModelByProcessDefinitionId = (processDefinitionId: String): Promise<any> => {
    return http.get(this.url + "/convertToModelByProcessDefinitionId", { processDefinitionId });
  };
  convertToModelByProcessInstanceId = (processInstanceId: String): Promise<any> => {
    return http.get(this.url + "/convertToModelByProcessInstanceId", { processInstanceId });
  };
  suspendProcessDefinitionById = (processDefinitionId: String): Promise<any> => {
    return http.get(this.url + "/suspendProcessDefinitionById", { processDefinitionId });
  };
  activateProcessDefinitionById = (processDefinitionId: String): Promise<any> => {
    return http.get(this.url + "/activateProcessDefinitionById", { processDefinitionId });
  };
  processDefinitionListByKey = (processDefinitionKey: String): Promise<any> => {
    return http.get(this.url + "/processDefinitionListByKey", { processDefinitionKey });
  };
  deploymentList = (params: any): Promise<any> => {
    return http.get(this.url + "/deploymentList", params);
  };
  deleteDeployment = (id: any): Promise<any> => {
    return http.delete(this.url + "/deleteDeployment", { id });
  };
  todoList = (params: any): Promise<any> => {
    return http.get(this.url + "/todoList", params);
  };
  todoneList = (params: any): Promise<any> => {
    return http.get(this.url + "/todoneList", params);
  };
  applyList = (params: any): Promise<any> => {
    return http.get(this.url + "/applyList", params);
  };
}
export default new MicroCamundaApi("/micro/camunda");
